<?php
/**
 * 免押金额度申请页面
 * User: tengyu
 * Date: 2017/10/30
 * Time: 13:42
 */?>
@extends('common.common')
@section('title','申请信用额度')
@section('css')
    <link rel="stylesheet" href="{{asset('/css/improve_deposit.css')}}">
@endsection
@section('js')
    <script src="{{asset('/js/improve_deposit.js')}}"></script>
<script>
    function getzhima()
    {
        $("#getzhima").submit();
    }
    /**简答信息填写校验*/
    function quota_apply()
    {
        var company_name = $("input[name='company_name']").val();
     /*   if(!company_name){
            alert('公司名不能为空');return false;
        }*/
        var company_phone = $("input[name='company_phone']").val();
      /*  if(!company_phone){
            alert('公司联系方式不能为空!');return false;
        }*/
        var company_addr = $("input[name='company_addr']").val();
      /*  if(!company_addr){
            alert('公司地址不能为空!');return false;
        }*/
        var company_img = $("input[name='company_img']").val();
      /*  if(!company_img){
            alert('请上传真实公司营业执照图片!');return false;
        }*/
        var name=$("input[name='username']").val();
        if(!name){
            alert('姓名不能为空!');return false;
        }
        var userphone = $("input[name='userphone']").val();
        if(!userphone){
            alert('请上传手机号!');return false;
        }
        if(!(/^1[3|4|5|7|8][0-9]\d{8}$/.test(userphone))) {
            alert('请输入正确手机号!');
            $("input[name='userphone']").focus();return false;
        }
        var identificatiomn = $("input[name='identificatiomn']").val();
        if(!identificatiomn){
            alert('身份证不能为空!');return false;
        }
        /**数据库有的值与页面是否有图片判断图片有没有上传提示*/
        var ident_face_src = $("#idZpic img").attr('src');
        var idZup_file = $("#idZup").val();
        if(!idZup_file && !ident_face_src){
            alert('请上传身份证正面照片!');return false;
        }
        var ident_backface_src = $("#idBpic img").attr('src');
        var idBup_file = $("#idBup").val();
        if(!ident_backface_src && !idBup_file){
            alert('请上传身份证背面照片!');return false;
        }
        return true;
    }
</script>
@endsection
@section('content')
    <div id="content">
        @include('common.centernav')
        @if (count($errors) > 0)
            <div class="alert alert-danger text-left">
                <strong>申请信息有误!</strong>
                <ul>
                    @if(is_object($errors))
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    @else
                        <li>{{$errors}}</li>
                    @endif
                </ul>
            </div>
        @endif
        <h3>个人中心</h3>
        <div class="container">
            <div class="row">
            @include('usercenter.usersidebar')
                <div class="col-xs-9">
                    <div class="panel panel-default rightPanel">
                        <div class="panel-heading"><h4>申请信用额度</h4></div>
                        <div class="panel-body">
                            <div class="company_information">公司信息</div>
                            <div id="information">
                                <form class="form-horizontal" action="{{url('/user/quota_post')}}" method="post"  enctype="multipart/form-data" onsubmit="return quota_apply()">
                                    {!! csrf_field() !!}
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">公司名称:</label>
                                        <div class="col-xs-5">
                                        @if(isset($param['quota_apply_dt']->company_name) && $param['quota_apply_dt']->company_name !='')
                                            <input type="text" class="form-control" name="company_name"  value="{{$param['quota_apply_dt']->company_name}}" readonly>
                                        @else
                                            <input type="text" class="form-control" name="company_name" value="" >
                                        @endif
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">公司固定电话：</label>
                                        <div class="col-xs-5">
                                        @if(isset($param['quota_apply_dt']->company_phone) && $param['quota_apply_dt']->company_phone !='')
                                            <input type="text" class="form-control" name="company_phone" value="{{$param['quota_apply_dt']->company_phone}}" readonly>
                                        @else
                                            <input type="text" class="form-control" name="company_phone" value="">
                                        @endif
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">办公地址：</label>
                                        <div class="col-xs-5">
                                        @if(isset($param['quota_apply_dt']->company_addr) && $param['quota_apply_dt']->company_addr!='')
                                            <input type="text" class="form-control" name="company_addr" value="{{$param['quota_apply_dt']->company_addr}}" readonly>
                                        @else
                                            <input type="text" class="form-control" name="company_addr"  value="">
                                        @endif
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">统一社会信用代码：</label>
                                        <div class="col-xs-5">
                                        @if(isset($param['quota_apply_dt']->socialcredit) && $param['quota_apply_dt']->socialcredit!='')
                                            <input type="text" class="form-control" name="socialcredit" value="{{$param['quota_apply_dt']->socialcredit}}" readonly>
                                        @else
                                            <input type="text" class="form-control" name="socialcredit" value="">
                                        @endif
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">营业执照照片：</label>
                                        <div id="circle" class="col-xs-6 upload">
                                        @if(isset($param['quota_apply_dt']->company_img) && $param['quota_apply_dt']->company_img!='')
                                            <img class="upImg" src="{{asset($param['quota_apply_dt']->company_img)}}" alt="营业执照照片">
                                        @else
                                            <div class="circle">+</div>
                                            <p class="up">点击上传</p>
                                        @endif
                                        </div>
                                        <input type="file" id="inputs" name="company_img">
                                        <div class="col-xs-4">请上传真实营业执照<br>支持格式JPG、PNG、GIF<br>最大支持8M</div>
                                    </div>
                                    <div class="company_information">一位法人或股东个人信息</div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">姓名：</label>
                                        <div class="col-xs-5">
                                            <input type="text" class="form-control" name="username" @if($param['quota_apply_dt']) value="{{$param['quota_apply_dt']->username}}" readonly @else value="" @endif>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">手机号码：</label>
                                        <div class="col-xs-5">
                                            <input type="text" class="form-control" name="userphone" @if($param['quota_apply_dt']) value="{{$param['quota_apply_dt']->userphone}}" readonly @else value="" @endif>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">身份证号码：</label>
                                        <div class="col-xs-5">
                                            <input type="text" class="form-control" name="identificatiomn" @if($param['quota_apply_dt']) value="{{$param['quota_apply_dt']->identificatiomn}}" readonly @else value="" @endif>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">法人紧急联系人：</label>
                                        <div class="col-xs-2 mergency">
                                            <input type="text" class="form-control" name="relationship" @if($param['quota_apply_dt']) value="{{$param['quota_apply_dt']->relationship}}" readonly @else value="" @endif placeholder="关系">
                                        </div>
                                        <div class="col-xs-2 mergency">
                                            <input type="text" class="form-control" name="relatedname" @if($param['quota_apply_dt']) value="{{$param['quota_apply_dt']->relatedname}}" readonly @else value="" @endif placeholder="姓名">
                                        </div>
                                        <div class="col-xs-2 mergency">
                                            <input type="text" class="form-control" name="relatedphone" @if($param['quota_apply_dt']) value="{{$param['quota_apply_dt']->relatedphone}}" readonly @else value="" @endif placeholder="联系方式">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3 control-label">身份证照片：</label>
                                        <div id="idZpic" class="col-xs-6 upload">
                                            @if(empty($param['quota_apply_dt']))
                                            <div class="circle">+</div>
                                            <p class="up">点击上传正面</p>
                                            @else
                                            <img class="upImg" src="{{asset($param['quota_apply_dt']->ident_face)}}" alt="身份证照片正面">
                                            @endif
                                        </div>
                                        <input type="file" id="idZup" name="ident_face">
                                        @if($param['quota_apply_dt'])
                                        <input type="hidden" name="ident_zup" value="2">
                                        @endif
                                        <div id="idBpic" class="col-xs-6 upload">
                                            @if(!$param['quota_apply_dt'])
                                                <div class="circle">+</div>
                                                <p class="up">点击上传背面</p>
                                            @else
                                                <img class="upImg" src="{{asset($param['quota_apply_dt']->ident_backface)}}" alt="身份证照片背面">
                                            @endif
                                        </div>
                                        <input type="file" id="idBup" name="ident_backface">
                                    </div>
                                    <div class="form-group">
                                        <label class="col-xs-3"></label>
                                        <div class="col-xs-7">请上传真实有效身份证照片，支持格式JPG、PNG、GIF，最大支持8M</div>
                                    </div>
                                    @if(empty($param['quota_apply_dt']) || (isset($param['quota_apply_dt']->company_name) && $param['quota_apply_dt']->company_name=='') || (isset($param['quota_apply_dt']->company_phone) && $param['quota_apply_dt']->company_phone=='')
                                    || (isset($param['quota_apply_dt']->company_addr) && $param['quota_apply_dt']->company_addr=='') || (isset($param['quota_apply_dt']->socialcredit) && $param['quota_apply_dt']->socialcredit=='') ||
                                    (isset($param['quota_apply_dt']->company_img) && $param['quota_apply_dt']->company_img==''))
                                    <div class="form-group">
                                        <label class="col-xs-3"></label>
                                        <div class="col-xs-7"><button class="btn btn-warning">立即申请</button></div>
                                    </div>
                                    @endif
                                </form>
                                @if(!empty($param['quota_data']) && $param['quota_data']->quota_zhima<1)
                                    <div class="form-group" style="padding-bottom: 50px;">
                                        <label class="col-xs-3" style="text-align: right;">芝麻信用：</label>
                                        <div class="col-xs-7" style="padding-left: 8px;">
                                            <button data-toggle="modal" data-target="#depositModalBox" class="btn btn-warning">立即开通</button>
                                        </div>
                                    </div>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @if(!empty($param['quota_apply_dt']))
    <div id="depositModalBox" class="modal" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <span class="close" data-dismiss="modal">&times;</span>
                    <h4 class="modal-title">申请提升额度</h4>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <img src="/img/zmxy.png" class="img-responsive">
                        <p class="words">尊敬的客户您好，请您授权芈租界查看您的芝麻信用分，我们会根据您的芝麻信用分给您授予免押金额度，谢谢您的配合。</p>
                    </div>
                    <form class="form-inline" action="{{url('/user/getzhima')}}" type="get" id="getzhima">
                        <div class="form-group">
                            <label class="control-label">姓名：</label>
                            <input type="text" class="form-control" name="quota_apply_name" value="{{$param['quota_apply_dt']->username}}" readonly>
                        </div>
                        <br><br>
                        <div class="form-group">
                            <label class="control-label">身份证号：</label>
                            <input type="text" class="form-control" name="quota_apply_ident" value="{{$param['quota_apply_dt']->identificatiomn}}" readonly>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-dismiss="modal" onclick="getzhima()">授权我的芝麻信用分</button>
                </div>
            </div>
        </div>
    </div>
    @endif
@endsection
